<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>结算</title>
<link rel="stylesheet" type="text/css" href="/style/css/base.css"/>
<link rel="stylesheet" type="text/css" href="/style/css/swiper.min.css"/>
<link rel="stylesheet" type="text/css" href="/style/css/xshop.css?ver=20180710"/>
<link rel="stylesheet" type="text/css" href="/style/css/sweet-alert.css"/>	
<script src="/style/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/style/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/style/js/xShop.js" type="text/javascript" charset="utf-8"></script>
<script src="/style/js/sweet-alert.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body class="checkout">
<div class="outwrap">
	<div class="in-mian5 checkout">

		<div class="sh-info">
			<?php
			if($this->address)
			{
			?>
			<div class="shmain clearfix">
				<a href="/cart/address?id=<?=$_GET['id'];?>">
					<h2 class="clearfix"><span class="name"><b><?=$this->address['realname'];?></b> <?=substr($this->address['mobile'],0,3).'****'.substr($this->address['mobile'],7,4);?></span></h2>
					<p><?=$this->address['province_name'].$this->address['city_name'].$this->address['county_name'].$this->address['address'];?></p>
				</a>
			</div>
			
			<?
			}
			else
			{
			?>
			<div class="add">
				<a href="/cart/address_add?cartid=<?=$_GET['cartid'];?>&back=checkout">添加收货地址&gt;&gt;</a>
			</div>
			<?	
			}
			?>
			<div class="line"></div>
		</div>
		<?php
		if($this->data)
		{
					$pic = '/style/images/img22.jpg';

					if($this->data['thumb_docid']>0 && $this->data['headimgurl']){
					    
					    $pic = $this->data['headimgurl'];
					}
					

					
		?>
		<div class="dingd-info">
			<dl class="clearfix">
				<dt><img src="<?=$pic;?>"/></dt>
				<dd><h2><?=stripslashes($this->data['goods_name']);?></h2><span class="price"><b><?=$this->data['bid_price'];?></b></span><span class="num">x1</span></dd>
			</dl>
		</div>
		
		<?
				
			
		}
		?>
				
		<form method="post" action="pay" id="frm">
		 <div class="dingd-ot-info">
			<dl class="clearfix">
				<dt>运费</dt>
				<dd class="shipping_fee">
					<?php
					if($this->shipping_fee >0)
					{
						echo '<span>'.$this->shipping_fee.'元</span>';
					} else
					{
						echo '免运费';
					}
				    if(!$this->member_level && $this->is_free_shipping <=0){ echo '<a href="/user/open">开通会员免运费</a>';}
					
					
					?>
				</dd>
			</dl>
			<dl class="clearfix">
				<dt>优惠券</dt>
				<dd class="coupon"><select name="coupon_id" id="select_coupon">
					
					<?php
					if($this->coupon)
					{
						echo '<option value="0">--选择优惠券--</option>';
						foreach($this->coupon as $r)
						{
							
							if($r['type']==1 && $this->shipping_fee >0 && $this->purchasing >0  && $this->is_free_shipping <=0)
							{


					?>
					<option value="<?=$r['coupon_id'];?>" data-money="<?=$r['money'];?>">免运费券 <?=date("Y-m-d",$r['expire_time']);?>到期</option>
					<?
							}
							elseif($r['type']==2)
							{
					?>
					<option<?=$this->total_price >=$r['need_money'] ? '' : ' disabled="disabled"';?>  value="<?=$r['coupon_id'];?>" data-money="<?=$r['money'];?>" data-needmoney="<?=$r['need_money'];?>">满<?=$r['need_money'];?>抵<?=($r['money'] * 1);?> <?=date("Y-m-d",$r['expire_time']);?>到期</option>
					<?			
							}
						}
					}
					else
					{
						echo '<option value="0">暂无可用优惠券</option>';
					}
					?>
				</select></dd>
			</dl>
			<dl class="clearfix">
				<dt>留言</dt>
				<dd><input type="text" class="txt" placeholder="选填，想要对我们的留言" name="remark"/></dd>
			</dl>
			
		</div> 
		<input type="hidden" name="act" value="save">
		<input type="hidden" name="id" value="<?=$_GET['id'];?>">
		<input type="hidden" name="address_id" id="address_id" value="<?=$this->address['id'];?>">
		<input type="hidden" name="declaration" id="declaration" value="<?=$this->declaration;?>">
		
		</form>
	</div>

	<!--底部导航-->
	<div class="foot-js">
		<div>
		<span class="gongjsp">共<b><?=$total_number;?></b>件商品<span class="tprice"><b><?=$this->total_price;?></b></span> <span class="gongtxt">(含运费)</span></span>
        <a class="settle_btn" href="javascript:settle_btn();" id="btn-qrzf">确认支付</a>
    	</div>
	</div>
	
	<div class="blackbg"></div>
	<div class="tczf">
		<span class="close"></span>
		<h2>确认付款</h2>
		<h4><b><?=$this->total_price;?></b></h4>
		<ul>
			<li><i class="ico ico-1"><img src="/style/images/tb_wx.png"/></i><span>微信支付</span></li>			
		</ul>
		<a href="javascript:_saveOrder();" class="btn-ljfk">立即付款</a>
	</div>	
</div>

<script type="text/javascript">
var _total_price = <?=$this->total_price;?>;
function isIphoneX(){
    return /iphone/gi.test(navigator.userAgent) && (screen.height == 812 && screen.width == 375)
}    
$(document).ready(function(e){
    // 判断iPhoneX
    if(isIphoneX())
    {
        $(".foot-js").addClass("iPhoneX");
    }

    $("#select_coupon").bind("change",function(){
    	var _new_money = _total_price;
    	$(".tprice b,.tczf h4 b").html(_new_money.toFixed(2));    	
    	if($(this).val() > 0)
    	{
    		var _money = parseFloat( $("#select_coupon option:selected").attr("data-money") ),_new_money = _total_price;
    		if(_money>0)
    		{
    			_new_money -= _money;
    			$(".tprice b,.tczf h4 b").html(_new_money.toFixed(2));
    		}
    	}

    })
});

function settle_btn()
{
	var type=true;
	

	if(type){
		$(".tczf").show();
		$('.blackbg').show();

	}else{
		$('.blackbg').hide();
		$(".tczf").hide();
	}
}


var _act = false;
function _saveOrder()
{
	if(!_act)
	{
		if( $("#address_id").prop("value")=="")
		{
			swal("请选择收货人");
			return   false;
		}
		_act = true;
		$("#frm").submit();
	}
	
}

</script>

</body>
</html>
